package com.google.gwt.it2tool.client;

import java.io.Serializable;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;



public class Factory implements Serializable,Comparable<Factory>{
	
	private String id;	
	private String name;
	private int area;
	
	private List<Production> productions = new ArrayList<Production>();

	public Factory() {
		super();
	}

	public Factory(String name) {
		this.name = name;	
		id = new Timestamp(new Date().getTime()) + IdGenerator.getNextId();		
	}
	
	public Factory(String name, String id, ArrayList<Production> productions){
		this.name=name;
		this.id=id;
		this.productions.addAll(productions);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getArea() {
		return area;
	}

	public void setArea(int area) {
		this.area = area;
	}
	
	public String getId(){
		return id;
	}
	
	public void setId(String id){
		this.id=id;
	}
	
	public void addProduction(Production prod){
		productions.add(prod);
	}
	
	public void removeProduction(Production prod){
		productions.remove(prod);
	}
	
	public int getProductionsCount(){
		return productions.size();
	}
	
	public ArrayList<Production> getProductions(){
		return (ArrayList<Production>) productions;
	}
	
	public void setProductions(List<Production> prods){
		productions=prods;
	}

	@Override
	public int compareTo(Factory arg0) {
		return this.getId().compareTo(arg0.getId());
	}
}
